﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Text;

namespace TTLL.Asm.Test.FromText
{
    [TestClass]
    public class UnitTest_FromStr
    {
        [TestMethod]
        public void Test001_LoadFile()
        {
            var filename = "FromText/code1.asm";
            var file = System.IO.File.ReadAllText(filename);
            Console.WriteLine(file);

            var words = TTLL.Asm.Word.WordScanner.Scan(file);
            Console.WriteLine("===========DumpWord=========");
            foreach (var w in words)
            {
                Console.WriteLine(w.ToString());
            }

        }
        [TestMethod]
        public void Test001_ParseFile01()
        {
            var filename = "FromText/code1.asm";
            var file = System.IO.File.ReadAllText(filename);
            Console.WriteLine(file);

            var module = TTLL.Asm.FromText.LoadModule(file);
            var bytes = TTLL.Asm.ToBin.SaveModule(module);
            var module2 = TTLL.Asm.FromBin.LoadModule(bytes);
            var files = TTLL.Asm.ToText.SaveModuleToString(module2);
            foreach (var f in files)
            {
                Console.WriteLine("=====reoutput " + f.Key + " =====");
                Console.WriteLine(f.Value);
            }
        }
        [TestMethod]
        public void Test001_ParseFile_Loop()
        {
            var filename = "FromText/code_loop.asm";
            var file = System.IO.File.ReadAllText(filename);
            Console.WriteLine(file);

            var module = TTLL.Asm.FromText.LoadModule(file);
            var bytes = TTLL.Asm.ToBin.SaveModule(module);
            var module2 = TTLL.Asm.FromBin.LoadModule(bytes);
            var files = TTLL.Asm.ToText.SaveModuleToString(module2);
            foreach (var f in files)
            {
                Console.WriteLine("=====reoutput " + f.Key + " =====");
                Console.WriteLine(f.Value);
            }
        }
    }
}
